/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  							 script_material_action.h

	$Header: /heroes4/script_material_action.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( SCRIPT_MATERIAL_ACTION_H_INCLUDED )
#define SCRIPT_MATERIAL_ACTION_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <iosfwd>

#include "material_array.h"
#include "script_target_type.h"
#include "script_targeted_action.h"

class t_basic_dialog;

// --------------------------------------------------------------------------
// t_script_material_action class
// --------------------------------------------------------------------------

class t_script_material_action
	:	public t_script_targeted_action< t_script_player_target >
{
public:
	// Member functions
	t_material_array const &	get_materials() const;
	
	virtual void		add_icons(t_basic_dialog* dialog) const; 

	virtual void		execute(t_script_context_hero const& context) const;
	virtual void		execute(t_script_context_town const& context) const;
	virtual void		execute(t_script_context_object const& context) const;
	virtual void		execute(t_script_context_army const& context) const;
	virtual void		execute(t_script_context_global const& context) const;

	virtual bool		read( std::streambuf& stream, int version );
	virtual bool		write( std::streambuf& stream ) const;

protected:
	// Data members
	t_material_array	m_materials;
};

class t_script_take_material 
	:	public t_script_material_action
{
public:
	virtual bool	read_from_map(
						std::streambuf &	stream,
						int					format_version );
};

class t_script_give_material 
	:	public t_script_material_action
{
public:
	virtual bool	read_from_map(
						std::streambuf &	stream,
						int					format_version );
};


// --------------------------------------------------------------------------
// t_script_material_action members
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_material_array const &
t_script_material_action::get_materials() const
{
	return m_materials;
}

SPECIALIZE_SCRIPT_ACTION( k_script_action_give_materials, t_script_give_material );
SPECIALIZE_SCRIPT_ACTION( k_script_action_take_materials, t_script_take_material );

#endif // !defined( SCRIPT_MATERIAL_ACTION_H_INCLUDED )
